/* 
   Copyright(C)2012 Fredy Ramirez - www.pacificcoolwave.com
 
   This file is part of the TerraCool project.
	
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

using System;
using System.Reflection;
using System.Threading;

namespace Pcw.TerraCool.Util
{
	internal static class Show
	{
		internal static void Head()
		{
			Console.WriteLine();
			Console.WriteLine(string.Format("TerraCoolUtil v{0}" + 
			                                "\nCopyright (C) 2012 Fredy Ramirez" + 
			                                "\nhttp://www.pacificcoolwave.com",
							Assembly.GetExecutingAssembly().GetName().Version.ToString()));
			Console.WriteLine(TerraCool.GetString("Current culture:") + " " + Thread.CurrentThread.CurrentCulture.Name + "\n");
		}

		internal static void License()
		{
			Console.WriteLine(TerraCool.GetString("Licensed under the Apache License, Version 2.0"));
			Console.WriteLine(TerraCool.GetString("TerraCool comes with ABSOLUTELY NO WARRANTY.  This is free software,"));
			Console.WriteLine(TerraCool.GetString("and you are welcome to redistribute it under certain conditions."));
			Console.WriteLine();
			Console.WriteLine(TerraCool.GetString("For help, type TerraCoolUtil.exe -?"));
			Console.WriteLine();
		}
		internal static void Help()
		{
			Console.WriteLine(TerraCool.GetString("TerraCool Command line utility"));
			Console.WriteLine(TerraCool.GetString("Manage TerraCool xml locale files."));
			Console.WriteLine(TerraCool.GetString("Usage:"));
			Console.WriteLine("   TerraCoolUtil.exe [OPTION...]");
			Console.WriteLine();
			Console.WriteLine(TerraCool.GetString("Examples:"));
			Console.WriteLine("TerraCoolUtil.exe -c -s source1.cs,source2.cs -o result");
			Console.WriteLine("  " + TerraCool.GetString("Creates a xml locale template from files source1.cs and source2.cs"));
			Console.WriteLine("TerraCoolUtil.exe -u -s source1.cs,source2.cs -o result");
			Console.WriteLine("  " + TerraCool.GetString("Updates a xml locale file from files source1.cs and source2.cs"));
			Console.WriteLine("TerraCoolUtil.exe -m -s source1.xml,source2.xml -o result");
			Console.WriteLine("  " + TerraCool.GetString("Merges two xml locale files into result.xml."));
			Console.WriteLine();
			Console.WriteLine(TerraCool.GetString("Operation:"));
			WriteHelpSpacing("-c, --create", TerraCool.GetString("Create a new xml locale template file."));
			WriteHelpSpacing("-u, --update", TerraCool.GetString("Update a xml locale file."));
			WriteHelpSpacing("-m, --merge", TerraCool.GetString("Merge xml locale files into one xml locale file."));
			Console.WriteLine();

			Console.WriteLine(TerraCool.GetString("File options:"));
			WriteHelpSpacing("-s, --source [FILE1, FILE2,]", TerraCool.GetString("List of source files to process."));
			WriteHelpSpacing(null, TerraCool.GetString("Depending on the operation option, it can be c-sharp file, vb file, "));
			WriteHelpSpacing(null, TerraCool.GetString("xml template file, a solution (sln) file, a project (csproj) file"));
			WriteHelpSpacing("-d, --directory [PATH]", TerraCool.GetString( "Path where source files are located."));
			WriteHelpSpacing(null, TerraCool.GetString("Default: current directory."));
			WriteHelpSpacing("-o, --output [NAME]", TerraCool.GetString("Output locale file name."));
			WriteHelpSpacing("--overwrite-false", TerraCool.GetString("Do not overwrite output file. Default: True"));
			Console.WriteLine();

			Console.WriteLine(TerraCool.GetString("Source type options:"));
			WriteHelpSpacing("--type-csharp", TerraCool.GetString("C-Sharp type. This is default."));
			WriteHelpSpacing("--type-vb", TerraCool.GetString("Visual basic type."));
			Console.WriteLine();

			Console.WriteLine(TerraCool.GetString("Help options:"));
			WriteHelpSpacing("-l, --license", TerraCool.GetString("Shows license and warranty"));
			WriteHelpSpacing("-?, -h, --help", TerraCool.GetString("Shows this text. Others parameters will be ommited."));
			Console.WriteLine();
		}

		private static void WriteHelpSpacing(string s1, string s2) 
		{
			int totalSpace = 35;
			string result;
			string space = String.Empty;
			char c = ' ';
			
			if (String.IsNullOrEmpty(s1)) {
				space = new string(c, totalSpace);
				result = space + s2;
			}			
			else  {
				space = new string(c, totalSpace - s1.Length);
				result = s1 + space + s2;
			}
			
			Console.WriteLine(result);
		}
	}
}

